package com.css.fxfzxczh.modules.instrumentIntensity.verify;

import cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult;
import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler;
import com.css.fxfzxczh.modules.instrumentIntensity.vo.ImportExcelVo;
import com.css.fxfzxczh.util.PlatformObjectUtils;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;


@Component
public class InstrumentIntensityExcelVerifyHandler implements IExcelVerifyHandler<ImportExcelVo> {



    @Override
    public ExcelVerifyHandlerResult verifyHandler(ImportExcelVo importExcelVo) {

        ExcelVerifyHandlerResult result = new ExcelVerifyHandlerResult(true);
        StringBuilder message = new StringBuilder("");
        try {



            if (PlatformObjectUtils.isEmpty(importExcelVo.getStationLongitude())) {
                result.setSuccess(false);
                message.append("台站经度 不能为空！");
            }else{
                int scale = importExcelVo.getStationLongitude().scale();
                if(scale>3){
                    result.setSuccess(false);
                    message.append("台站经度 最多可输入3位小数！");
                }
            }
            if (PlatformObjectUtils.isEmpty(importExcelVo.getStationLatitude())) {
                result.setSuccess(false);
                message.append("台站纬度 不能为空！");
            }else{
                int scale = importExcelVo.getStationLatitude().scale();
                if(scale>3){
                    result.setSuccess(false);
                    message.append("台站纬度 最多可输入3位小数！");
                }
            }
            if (PlatformObjectUtils.isEmpty(importExcelVo.getInstrumentIntensity())) {
                result.setSuccess(false);
                message.append("仪器烈度 不能为空！");
            }else{
                int scale = importExcelVo.getInstrumentIntensity().scale();
                if(scale>1){
                    result.setSuccess(false);
                    message.append("仪器烈度 最多可输入1位小数！");
                }
            }



        } catch (Exception e) {

        }
        result.setMsg(message.toString());
        return result;
    }




}
